home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / PInterfaces / AppleEvents.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  13.8 KB  |  366 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        AppleEvents.p
  3.  
  4.      Contains:    AppleEvent Package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT AppleEvents;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __APPLEEVENTS__}
  27. {$SETC __APPLEEVENTS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC AppleEventsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MIXEDMODE__}
  37. {$I MixedMode.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __NOTIFICATION__}
  40. {$I Notification.p}
  41. {$ENDC}
  42. {$IFC UNDEFINED __EVENTS__}
  43. {$I Events.p}
  44. {$ENDC}
  45. {
  46.     Note:    The functions and types for the building and parsing AppleEvent  
  47.             messages has moved to AEDataModel.h
  48. }
  49. {$IFC UNDEFINED __AEDATAMODEL__}
  50. {$I AEDataModel.p}
  51. {$ENDC}
  52.  
  53.  
  54. {$PUSH}
  55. {$ALIGN MAC68K}
  56. {$LibExport+}
  57.  
  58.  
  59. CONST
  60.                                                                 {  Keywords for Apple event parameters  }
  61.     keyDirectObject                = '----';
  62.     keyErrorNumber                = 'errn';
  63.     keyErrorString                = 'errs';
  64.     keyProcessSerialNumber        = 'psn ';                        {  Keywords for special handlers  }
  65.     keyPreDispatch                = 'phac';                        {  preHandler accessor call  }
  66.     keySelectProc                = 'selh';                        {  more selector call  }
  67.                                                                 {  Keyword for recording  }
  68.     keyAERecorderCount            = 'recr';                        {  available only in vers 1.0.1 and greater  }
  69.                                                                 {  Keyword for version information  }
  70.     keyAEVersion                = 'vers';                        {  available only in vers 1.0.1 and greater  }
  71.  
  72. { Event Class }
  73.     kCoreEventClass                = 'aevt';
  74.  
  75. { Event ID’s }
  76.     kAEOpenApplication            = 'oapp';
  77.     kAEOpenDocuments            = 'odoc';
  78.     kAEPrintDocuments            = 'pdoc';
  79.     kAEQuitApplication            = 'quit';
  80.     kAEAnswer                    = 'ansr';
  81.     kAEApplicationDied            = 'obit';
  82.  
  83. { Constants for recording }
  84.     kAEStartRecording            = 'reca';                        {  available only in vers 1.0.1 and greater  }
  85.     kAEStopRecording            = 'recc';                        {  available only in vers 1.0.1 and greater  }
  86.     kAENotifyStartRecording        = 'rec1';                        {  available only in vers 1.0.1 and greater  }
  87.     kAENotifyStopRecording        = 'rec0';                        {  available only in vers 1.0.1 and greater  }
  88.     kAENotifyRecording            = 'recr';                        {  available only in vers 1.0.1 and greater  }
  89.  
  90.  
  91. { parameter to AESend }
  92.  
  93. TYPE
  94.     AESendOptions                        = OptionBits;
  95.  
  96. CONST
  97.     kAENeverInteract            = $00000010;                    {  server should not interact with user  }
  98.     kAECanInteract                = $00000020;                    {  server may try to interact with user  }
  99.     kAEAlwaysInteract            = $00000030;                    {  server should always interact with user where appropriate  }
  100.     kAECanSwitchLayer            = $00000040;                    {  interaction may switch layer  }
  101.     kAEDontRecord                = $00001000;                    {  don't record this event - available only in vers 1.0.1 and greater  }
  102.     kAEDontExecute                = $00002000;                    {  don't send the event for recording - available only in vers 1.0.1 and greater  }
  103.     kAEProcessNonReplyEvents    = $00008000;                    {  allow processing of non-reply events while awaiting synchronous AppleEvent reply  }
  104.  
  105.  
  106. TYPE
  107.     AESendMode                            = SInt32;
  108.  
  109. CONST
  110.     kAENoReply                    = $00000001;                    {  sender doesn't want a reply to event  }
  111.     kAEQueueReply                = $00000002;                    {  sender wants a reply but won't wait  }
  112.     kAEWaitReply                = $00000003;                    {  sender wants a reply and will wait  }
  113.     kAEDontReconnect            = $00000080;                    {  don't reconnect if there is a sessClosedErr from PPCToolbox  }
  114.     kAEWantReceipt                = $00000200;                    {  (nReturnReceipt) sender wants a receipt of message  }
  115.  
  116.  
  117. { Constants for timeout durations }
  118.     kAEDefaultTimeout            = -1;                            {  timeout value determined by AEM  }
  119.     kNoTimeOut                    = -2;                            {  wait until reply comes back, however long it takes  }
  120.  
  121.  
  122. { priority param of AESend }
  123.  
  124. TYPE
  125.     AESendPriority                        = SInt16;
  126.  
  127. CONST
  128.     kAENormalPriority            = $00000000;                    {  post message at the end of the event queue  }
  129.     kAEHighPriority                = $00000001;                    {  post message at the front of the event queue (same as nAttnMsg)  }
  130.  
  131.  
  132.  
  133. TYPE
  134.     AEEventSource                        = SInt8;
  135.  
  136. CONST
  137.     kAEUnknownSource            = 0;
  138.     kAEDirectCall                = 1;
  139.     kAESameProcess                = 2;
  140.     kAELocalProcess                = 3;
  141.     kAERemoteProcess            = 4;
  142.  
  143.  
  144.  
  145.  
  146. TYPE
  147. {$IFC TYPED_FUNCTION_POINTERS}
  148.     AEEventHandlerProcPtr = FUNCTION({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32): OSErr;
  149. {$ELSEC}
  150.     AEEventHandlerProcPtr = ProcPtr;
  151. {$ENDC}
  152.  
  153. {$IFC TYPED_FUNCTION_POINTERS}
  154.     AEIdleProcPtr = FUNCTION(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle): BOOLEAN;
  155. {$ELSEC}
  156.     AEIdleProcPtr = ProcPtr;
  157. {$ENDC}
  158.  
  159. {$IFC TYPED_FUNCTION_POINTERS}
  160.     AEFilterProcPtr = FUNCTION(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; {CONST}VAR sender: AEAddressDesc): BOOLEAN;
  161. {$ELSEC}
  162.     AEFilterProcPtr = ProcPtr;
  163. {$ENDC}
  164.  
  165.     AEEventHandlerUPP = UniversalProcPtr;
  166.     AEIdleUPP = UniversalProcPtr;
  167.     AEFilterUPP = UniversalProcPtr;
  168.  
  169. CONST
  170.     uppAEEventHandlerProcInfo = $00000FE0;
  171.     uppAEIdleProcInfo = $00000FD0;
  172.     uppAEFilterProcInfo = $00003FD0;
  173.  
  174. FUNCTION NewAEEventHandlerProc(userRoutine: AEEventHandlerProcPtr): AEEventHandlerUPP;
  175.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  176.     INLINE $2E9F;
  177.     {$ENDC}
  178.  
  179. FUNCTION NewAEIdleProc(userRoutine: AEIdleProcPtr): AEIdleUPP;
  180.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  181.     INLINE $2E9F;
  182.     {$ENDC}
  183.  
  184. FUNCTION NewAEFilterProc(userRoutine: AEFilterProcPtr): AEFilterUPP;
  185.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  186.     INLINE $2E9F;
  187.     {$ENDC}
  188.  
  189. FUNCTION CallAEEventHandlerProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32; userRoutine: AEEventHandlerUPP): OSErr;
  190.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  191.     INLINE $205F, $4E90;
  192.     {$ENDC}
  193.  
  194. FUNCTION CallAEIdleProc(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle; userRoutine: AEIdleUPP): BOOLEAN;
  195.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  196.     INLINE $205F, $4E90;
  197.     {$ENDC}
  198.  
  199. FUNCTION CallAEFilterProc(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; {CONST}VAR sender: AEAddressDesc; userRoutine: AEFilterUPP): BOOLEAN;
  200.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  201.     INLINE $205F, $4E90;
  202.     {$ENDC}
  203.  
  204. {*************************************************************************
  205.   The next couple of calls are basic routines used to create, send,
  206.   and process AppleEvents. 
  207. *************************************************************************}
  208. FUNCTION AESend({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP): OSErr;
  209.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  210.     INLINE $303C, $0D17, $A816;
  211.     {$ENDC}
  212. FUNCTION AEProcessAppleEvent({CONST}VAR theEventRecord: EventRecord): OSErr;
  213.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  214.     INLINE $303C, $021B, $A816;
  215.     {$ENDC}
  216.  
  217.  Note: during event processing, an event handler may realize that it is likely
  218.  to exceed the client's timeout limit. Passing the reply to this
  219.  routine causes a wait event to be generated that asks the client
  220.  for more time. 
  221. }
  222. FUNCTION AEResetTimer({CONST}VAR reply: AppleEvent): OSErr;
  223.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  224.     INLINE $303C, $0219, $A816;
  225.     {$ENDC}
  226.  
  227. {*************************************************************************
  228.   The following three calls are used to allow applications to behave
  229.   courteously when a user interaction such as a dialog box is needed. 
  230. *************************************************************************}
  231.  
  232.  
  233. TYPE
  234.     AEInteractAllowed                    = SInt8;
  235.  
  236. CONST
  237.     kAEInteractWithSelf            = 0;
  238.     kAEInteractWithLocal        = 1;
  239.     kAEInteractWithAll            = 2;
  240.  
  241. FUNCTION AEGetInteractionAllowed(VAR level: AEInteractAllowed): OSErr;
  242.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  243.     INLINE $303C, $021D, $A816;
  244.     {$ENDC}
  245. FUNCTION AESetInteractionAllowed(level: AEInteractAllowed): OSErr;
  246.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  247.     INLINE $303C, $011E, $A816;
  248.     {$ENDC}
  249. FUNCTION AEInteractWithUser(timeOutInTicks: LONGINT; nmReqPtr: NMRecPtr; idleProc: AEIdleUPP): OSErr;
  250.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  251.     INLINE $303C, $061C, $A816;
  252.     {$ENDC}
  253.  
  254. {*************************************************************************
  255.   These calls are used to set up and modify the event dispatch table.
  256. *************************************************************************}
  257. FUNCTION AEInstallEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr;
  258.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  259.     INLINE $303C, $091F, $A816;
  260.     {$ENDC}
  261. FUNCTION AERemoveEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; isSysHandler: BOOLEAN): OSErr;
  262.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  263.     INLINE $303C, $0720, $A816;
  264.     {$ENDC}
  265. FUNCTION AEGetEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; VAR handler: AEEventHandlerUPP; VAR handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr;
  266.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  267.     INLINE $303C, $0921, $A816;
  268.     {$ENDC}
  269.  
  270. {*************************************************************************
  271.  The following four calls are available for applications which need more
  272.  sophisticated control over when and how events are processed. Applications
  273.  which implement multi-session servers or which implement their own
  274.  internal event queueing will probably be the major clients of these
  275.  routines. They can be called from within a handler to prevent the AEM from
  276.  disposing of the AppleEvent when the handler returns. They can be used to
  277.  asynchronously process the event (as MacApp does).
  278. *************************************************************************}
  279. FUNCTION AESuspendTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr;
  280.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  281.     INLINE $303C, $022B, $A816;
  282.     {$ENDC}
  283.  Note: The following routine tells the AppleEvent manager that processing
  284.  is either about to resume or has been completed on a previously suspended
  285.  event. The procPtr passed in as the dispatcher parameter will be called to
  286.  attempt to redispatch the event. Several constants for the dispatcher
  287.  parameter allow special behavior. They are:
  288.       - kAEUseStandardDispatch means redispatch as if the event was just
  289.       received, using the standard AppleEvent dispatch mechanism.
  290.       - kAENoDispatch means ignore the parameter.
  291.          Use this in the case where the event has been handled and no
  292.       redispatch is needed.
  293.       - non nil means call the routine which the dispatcher points to.
  294. }
  295. { Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch }
  296.  
  297. CONST
  298.     kAEDoNotIgnoreHandler        = $00000000;
  299.     kAEIgnoreAppPhacHandler        = $00000001;                    {  available only in vers 1.0.1 and greater  }
  300.     kAEIgnoreAppEventHandler    = $00000002;                    {  available only in vers 1.0.1 and greater  }
  301.     kAEIgnoreSysPhacHandler        = $00000004;                    {  available only in vers 1.0.1 and greater  }
  302.     kAEIgnoreSysEventHandler    = $00000008;                    {  available only in vers 1.0.1 and greater  }
  303.     kAEIngoreBuiltInEventHandler = $00000010;                    {  available only in vers 1.0.1 and greater  }
  304.     kAEDontDisposeOnResume        = $80000000;                    {  available only in vers 1.0.1 and greater  }
  305.  
  306. { Constants for AEResumeTheCurrentEvent }
  307.     kAENoDispatch                = 0;                            {  dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch  }
  308.     kAEUseStandardDispatch        = $FFFFFFFF;                    {  table, or one of these two constants  }
  309.  
  310. FUNCTION AEResumeTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent; {CONST}VAR reply: AppleEvent; dispatcher: AEEventHandlerUPP; handlerRefcon: LONGINT): OSErr;
  311.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  312.     INLINE $303C, $0818, $A816;
  313.     {$ENDC}
  314. FUNCTION AEGetTheCurrentEvent(VAR theAppleEvent: AppleEvent): OSErr;
  315.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  316.     INLINE $303C, $021A, $A816;
  317.     {$ENDC}
  318. FUNCTION AESetTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr;
  319.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  320.     INLINE $303C, $022C, $A816;
  321.     {$ENDC}
  322.  
  323. {*************************************************************************
  324.   These calls are used to set up and modify special hooks into the
  325.   AppleEvent manager.
  326. *************************************************************************}
  327. FUNCTION AEInstallSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  328.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  329.     INLINE $303C, $0500, $A816;
  330.     {$ENDC}
  331. FUNCTION AERemoveSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  332.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  333.     INLINE $303C, $0501, $A816;
  334.     {$ENDC}
  335. FUNCTION AEGetSpecialHandler(functionClass: AEKeyword; VAR handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr;
  336.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  337.     INLINE $303C, $052D, $A816;
  338.     {$ENDC}
  339.  
  340. {*************************************************************************
  341.   This call was added in version 1.0.1. If called with the keyword
  342.   keyAERecorderCount ('recr'), the number of recorders that are
  343.   currently active is returned in 'result'
  344.   (available only in vers 1.0.1 and greater).
  345. *************************************************************************}
  346. FUNCTION AEManagerInfo(keyWord: AEKeyword; VAR result: LONGINT): OSErr;
  347.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  348.     INLINE $303C, $0441, $A816;
  349.     {$ENDC}
  350.  
  351.  
  352.  
  353.  
  354. {$ALIGN RESET}
  355. {$POP}
  356.  
  357. {$SETC UsingIncludes := AppleEventsIncludes}
  358.  
  359. {$ENDC} {__APPLEEVENTS__}
  360.  
  361. {$IFC NOT UsingIncludes}
  362.  END.
  363. {$ENDC}
  364.